package com.briup.web.servlet;

import com.briup.bean.Book;
import com.briup.service.IBookService;
import com.briup.service.impl.IBookServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Locale;

/**
 * @author 王若龙
 * @CreateTime 2022-09-23 16:00
 */
@WebServlet("/viewBook")
public class ViewBookServlet extends HttpServlet {

    private IBookService bookService = new IBookServiceImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int id = Integer.parseInt(req.getParameter("id").trim());
        Book book = bookService.findBookById(id);
        req.getSession().setAttribute("book", book);
        resp.sendRedirect("viewBook.jsp");
    }
}
